
//
//  XQMSView.m
//  yonghu
//
//  Created by mac on 2018/3/19.
//  Copyright © 2018年 com.DJS. All rights reserved.
//

#import "XQMSView.h"
#import "XQMSTableViewCell.h"
@implementation XQMSView
-(void)creatView{
    self.backgroundColor=[UIColor colorWithRed:0 green:0 blue:0 alpha:0.3];
    UIView *view=[UIView new];
    [self addSubview:view];
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.mas_equalTo(0);
        make.width.mas_equalTo(_mainW*0.7);
        make.height.mas_equalTo(_mainH*0.6);
    }];
    view.backgroundColor=[UIColor whiteColor];
    view.layer.cornerRadius=4;
    
    UIView *topView=[UIView new];
    [view addSubview:topView];
    [topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.mas_equalTo(0);
        make.height.mas_equalTo(55);
    }];
    topView.backgroundColor=_backgroundColor;
    
    UILabel *titleLabel=[UILabel new];
    [topView addSubview:titleLabel];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.mas_equalTo(0);
    }];
    titleLabel.text=@"案件类型";
    titleLabel.font=[UIFont systemFontOfSize:18];
    titleLabel.textColor=[UIColor whiteColor];
    
    _tableView=[BaseTableView new];
    [view addSubview:_tableView];
    [_tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.mas_equalTo(0);
        make.top.mas_equalTo(topView.mas_bottom);
    }];
    _tableView.delegate=self;
    _tableView.dataSource=self;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

    
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    return _typeArr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    XQMSTableViewCell *cell=[[XQMSTableViewCell alloc] init];
    cell.dic=_typeArr[indexPath.row];
    cell.row=indexPath.row+1;
    [cell setFrame:CGRectMake(0, 0, _mainW*0.7, [cell creatView])];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [self tableView:_tableView cellForRowAtIndexPath:indexPath];
    return cell.frame.size.height;
}
#pragma mark————————————————————点击屏幕关闭键盘
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    
    //    make.width.mas_equalTo(_mainW*0.7);
    //    make.height.mas_equalTo(_mainH*0.6);
    
    UITouch *touch = [touches anyObject];
    CGPoint touchPoint = [touch locationInView:self ];
    
    if (!(touchPoint.y>_mainH/2-_mainH*0.3&&touchPoint.y<_mainH/2+_mainH*0.3&&touchPoint.x>_mainW*0.15&&touchPoint.x<_mainW*0.85)) {
        [self removeFromSuperview];
    }
}
@end
